package ninja.awesome.game.gameobject;

import ninja.awesome.framework.Graphics;
import ninja.awesome.framework.Image;
import ninja.awesome.framework.Sound;
import ninja.awesome.game.Assets;
import ninja.awesome.game.MainGameScreen;
import ninja.awesome.game.classes.Friendly;
import ninja.awesome.game.compat.Rectangle;
import ninja.awesome.game.main.Animation;
import ninja.awesome.game.main.Controller;
import ninja.awesome.game.main.Sprites;

public class Shuriken extends GameObj implements Friendly {

	private String direction;
	private int speed = 16;
	private int timer = 0;
	private boolean hit = false;
	private Image[] image;
	MainGameScreen game;
	Sprites s;
	Sound boom;
	Animation ninjaStar;
	Controller c;

	public Shuriken(int x, int y, String direction, MainGameScreen game, Controller c, Sprites s) {
		super(x, y);
		this.game = game;
		this.c = c;
		this.direction = direction;
		this.s = s;
		boom = Assets.boom;
		image = this.s.getShuriken();
		ninjaStar = new Animation(5, image[0], 15, 15, 8);
	}

	@Override
	public void update() {
		if (!hit) {
			if (direction == "right") {
				xLoc += speed;
			}
			if (direction == "left") {
				xLoc -= speed;
			}
		} else if (hit) {
			if (timer >= 30) {
				c.removeFriendly(this);
			}
			timer++;
		}
	}

	@Override
	public void draw(Graphics g) {
		if (!hit) {
			ninjaStar.runAnimation();
			ninjaStar.drawAnimation(g, xLoc, yLoc);
		}
	}

	@Override
	public Rectangle getBounds() {
		return new Rectangle(xLoc, yLoc, 15, 15);
	}

	// GETTERS
	@Override
	public int getX() {
		return xLoc;
	}

	@Override
	public int getY() {
		return yLoc;
	}

	// Setters
	public void SetX(int x) {
		this.xLoc = x;
	}

	public void SetY(int y) {
		this.yLoc = y;
	}

	public int getTimer() {
		return timer;
	}

	public void setTimer(int timer) {
		this.timer = timer;
	}

	public boolean getHit() {
		return hit;
	}

	public void setHit(boolean hit) {
		this.hit = hit;
	}

}
